<template>
<div class="battle">
    <div class="info">错题本页面</div>
    <div class="btnClass">
      <button class="cu-btn lg" :style='style' @click="changeColor">测试</button>
    </div>
</div>
</template>

<script>
import backgroundimg from '@/components/backgroundimg'

export default {
  data () {
    return {
      style: 'background-color:red',
      nickName: '',
      avatarUrl: '',
      score: ''
    }
  },
  components: {
    backgroundimg
  },
  methods: {
    changeColor () {
      this.style = 'background-color:white'
    },
    setting () {
      wx.sendSocketMessage({
        data: JSON.stringify(
          {
            'type': 'finish'
          }
        ),
        success: function (e) {
          console.log('对战结束')
        },
        fail: function (e) {
          console.log(e)
        }
      })
      wx.request({
        url: process.env.BASE_API + '/setScore',
        method: 'GET',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          avatarUrl: this.avatarUrl,
          score: this.score
        },
        success: function (res) {
          console.log('chenggong')
        },
        fail: function (error) {
          console.log(error)
        }
      })
    }
  },
  onLoad: function (options) {
    this.nickName = options.nickName
    this.avatarUrl = options.avatarUrl
    this.score = options.score1
    this.setting()
  }
}
</script>

<style>
.battle{
    background: url("");
    background-size: 100% 100%;
    height:100%;
    width:100%;
    position: absolute;
}
.info{
color:aliceblue;
position:absolute;
left: 115px;
font-size: 30px;
}
</style>
